package dao

import (
	"go.uber.org/zap"
	"gorm.io/gorm"
)

type DaoContainer struct {
	SysUserDao      *SysUserDao
	SysUserRolesDao *SysUserRolesDao
	SysMenuDao      *SysMenuDao
	SysRoleDao      *SysRoleDao
	SysRoleMenuDao  *SysRoleMenuDao
	DeptDao         *DeptDao
	SysDictItemDao  *SysDictItemDao
	SysDictDao      *SysDictDao
	LogDao          *LogDao
}

// CreateDaoInstance 创建单例
func CreateDaoInstance(db *gorm.DB, logger *zap.Logger) *DaoContainer {
	sysUserRolesDao := NewSysUserRolesDao(db, logger)
	sysUserDao := NewSysUserDao(db, sysUserRolesDao, logger)
	menuDao := NewSysMenuDao(db, logger)
	sysRoleDao := NewSysRoleDao(db, sysUserRolesDao, logger)
	deptDao := NewDeptDao(db, logger)
	sysRoleMenuDao := NewSysRoleMenuDao(db, sysUserRolesDao, logger)
	sysDictItemDao := NewSysDictItemDao(db, logger)
	sysDictDao := NewSysDictDao(db, sysDictItemDao, logger)
	logDao := NewLogDao(db, logger)
	return &DaoContainer{
		sysUserDao,
		sysUserRolesDao,
		menuDao,
		sysRoleDao,
		sysRoleMenuDao,
		deptDao,
		sysDictItemDao,
		sysDictDao,
		logDao,
	}
}
